
package com.my.xadmin.security.repository;
import com.my.framework.base.repository.BaseJpaDao;
import com.my.xadmin.security.entity.Module;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;

import javax.persistence.QueryHint;
import java.util.List;


public interface ModuleDAO extends BaseJpaDao<Module, Long> {
	Page<Module> findByParentId(Long parentId, Pageable pageable);
	
	Page<Module> findByParentIdAndNameContaining(Long parentId, String name, Pageable pageable);
	
//	@QueryHints(value={
//			@QueryHint(name="org.hibernate.cacheable",value="true"),
//			@QueryHint(name="org.hibernate.cacheRegion",value="com.wondersgroup.framework.entity.main")
//		}
//	)
	@Query("from Module m order by m.priority ASC")
	List<Module> findAllWithCache();
	
	/**
	 * 根据sn，查找Module
	 * 描述
	 * @param sn
	 * @return
	 */
	List<Module> findBySn(String sn);
}
